# teste movimentos #

background_image = 'fundo.jpg'
sprite_image = 'xiao.png'

import pygame
from pygame.locals import *
from sys import exit

pygame.init()

screen = pygame.display.set_mode((640, 480), 0, 32)

background = pygame.image.load(background_image).convert()
sprite = pygame.image.load(sprite_image)

# objeto de relogio
clock = pygame.time.Clock()

# coordenada x do seu sprite
x = 0.

# velocidade do jogo
speed = 250.

while True:
    for event in pygame.event.get():
        if event.type == QUIT:
            exit()

    screen.blit(background, (0,0))
    screen.blit(sprite, (x,200))

    time_passed = clock.tick()
    segundos_passados = time_passed / 1000.0

    distance_moved = segundos_passados * speed 
    x += distance_moved
    # se a imagem sair da tela ela volta
    if x > 640.:
        x -= 640.

    pygame.display.update()
